package com.edu.exam.entity.examination.paper.technical;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import jakarta.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 处理统计实体类
 *
 * 根据E-04-01设备适配子模块数据库设计实现
 * 存储识别处理的统计数据信息。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class ProcessingStatistics {

    /**
     * 统计ID，主键
     */
    @Id
    @Column(name = "stat_id", length = 64)
    private String statId;

    /**
     * 统计日期
     */
    @Column(name = "stat_date", nullable = false)
    private LocalDate statDate;

    /**
     * 考试ID
     */
    @Column(name = "exam_id", length = 64, nullable = false)
    private String examId;

    /**
     * 总任务数量
     */
    @Column(name = "total_tasks", nullable = false)
    private Integer totalTasks;

    /**
     * 已完成任务数量
     */
    @Column(name = "completed_tasks", nullable = false)
    private Integer completedTasks;

    /**
     * 失败任务数量
     */
    @Column(name = "failed_tasks", nullable = false)
    private Integer failedTasks;

    /**
     * 总图片数量
     */
    @Column(name = "total_images", nullable = false)
    private Integer totalImages;

    /**
     * 已处理图片数量
     */
    @Column(name = "processed_images", nullable = false)
    private Integer processedImages;

    /**
     * 失败图片数量
     */
    @Column(name = "failed_images", nullable = false)
    private Integer failedImages;

    /**
     * 平均处理时间（毫秒）
     */
    @Column(name = "avg_processing_time")
    private Long avgProcessingTime;

    /**
     * 平均质量分数
     */
    @Column(name = "avg_quality_score", precision = 5, scale = 2)
    private Double avgQualityScore;

    /**
     * 峰值并发数
     */
    @Column(name = "peak_concurrency")
    private Integer peakConcurrency;

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "updated_time")
    private LocalDateTime updatedTime;

    /**
     * 版本号（用于乐观锁）
     */
    @Version
    @Column(name = "version", nullable = false)
    private Long version = 0L;

    /**
     * 删除标记
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;
}